<?php

/*
	[BuyPg] (C) 2010-2011 Buypg
	$Id: NodeModel.class.php 2011-7-12 11:44:22 wufujun $
 */

if (!defined('THINK_PATH')) {
	exit('Access Denied');
}

class NodeModel extends CommonModel{
	protected $_validate	=	array(
		array('name','checkNode','节点已经存在',0,'callback'),
	);

	public function checkNode() {
		$map['name']	 =	 $_POST['name'];
		$map['pid']	=	isset($_POST['pid'])?$_POST['pid']:0;
		$map['status'] = 1;
		if(!empty($_POST['id'])) {
			$map['id']	=	array('neq',$_POST['id']);
		}
		$result	=	$this->where($map)->field('id')->find();
		if($result) {
			return false;
		}else{
			return true;
		}
	}
}
?>